﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
namespace WinFromMediaPlayerDemo.Common
{
    /// <summary>
    /// 数字文件名比较
    /// </summary>
    public class NumFileNameCompare : IComparer<string>
    {

        public int Compare(string x, string y)
        {
            string s1 = Path.GetFileNameWithoutExtension(x);
            string s2 = Path.GetFileNameWithoutExtension(y);
            int n1=0,n2=0;
            int.TryParse(s1, out n1);
            int.TryParse(s2, out n2);
            if (n1 > n2)
            {
                return 1;
            }
            else if(n1 == n2)
            {
                return 0;
            }
            else
            {
                return -1;
            }
        }
    }
}